<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>9.watch简写形式</title>
        <!-- 引入Vue -->
        <script src="../js/vue.js"></script>
    </head>
    <body>
        <!-- 准备好一个容器-->
        <div id="app">
            <h1>今天天气 : {{weather }}</h1>
            <button @click="isHot = !isHot">点击切换</button>
        </div>
    </body>

    <script>
        new Vue({
            el:"#app",
            data:{
                isHot:false
            },
            computed:{
                weather(){
                    return this.isHot ? "炎热" : "凉爽"
                }
            },
            watch:{
                isHot(){
                    this.isHot ? console.log("吃个雪糕") : console.log("喝个奶茶");
                }
            }
        })
    </script>
</html>